<?php

/* @var $this \yii\web\View */
/* @var $content string */

use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use frontend\assets\AppAsset;
use common\widgets\Alert;

AppAsset::register($this);
?>
<?php $this->beginPage() ?>
<!DOCTYPE html>
<html lang="<?= Yii::$app->language ?>">
<head>
    <meta charset="<?= Yii::$app->charset ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
    <?php $this->head() ?>
</head>
<body>
<?php $this->beginBody() ?>

<div class="wrap">
    <?php
    NavBar::begin([
        //'brandLabel' => '我的博客',
        'brandLabel' =>Yii::t('common',"Yang"),
        'brandUrl' => Yii::$app->homeUrl,
        'options' => [
            'class' => 'navbar-inverse navbar-fixed-top',
        ],
    ]);
    
    $menuItemsLeft = [
        ['label' => '<i class="icon-home"> 首页 </i>', 'url' => ['/site/index']],
        //Imooc 学习
        ['label' => '<i class="icon-book"></i> Imooc 学习',
         'items'=>
         [
            ['label'=>'sql查询练习', 'url'=>['/sqlquery/index']],
            ['label'=>'imooc 学习', 'url'=>['/study/index']],
            ['label'=>'行为控制器', 'url'=>['/behavior/index']],
            ['label'=>'事件控制器', 'url'=>['/event/index']],

         ]
        ],    

        //测试
        ['label' => '<i class="icon-edit"> 测试</i>',
          'items'=>[
            ['label'=>'文件上传+富文本编辑器', 'url'=>['/upload/ued']],
            ['label'=>'Test 控制器', 'url'=>['/test/index']],
            ['label'=>'阿里短信发送+验证', 'url'=>['/sms/smshow']],
          ]
        ],

        //实战
        ['label' => '<i class="icon-thumbs-up"> 实战</i>', 
         'items'=>
         [
            ['label'=>' sql 练习实战','url'=>['/sqlcombat/index']],               
            ['label'=>' Api 练习','url'=>['/api/api']],  
         ]
        ],

        //文章
        ['label' => '<i class="icon-pencil"> 文章</i>', 
         'items'=>
         [
            ['label'=>' 文章列表','url'=>['/article/index']],               
            ['label'=>' 文章列表','url'=>['/article/add']],               
         ]
        ],

        //其它
        ['label' => '<i class="icon-time"></i> 其它',
         'items'=>
         [
            ['label' => '联系方式', 'url' => ['/site/contact']],
            ['label' => '关于我们', 'url' => ['/site/about']],
         ]
        ],


    ];

    if (Yii::$app->user->isGuest) {
        $menuItemsRight[] = ['label' => '注册', 'url' => ['/site/signup']];
        $menuItemsRight[] = ['label' => '登陆', 'url' => ['/site/login']];
    } else {
        $menuItemsRight[] =[
         'label'=>Yii::$app->user->identity->username,
         'items'=>[
             ['label'=>
            '<i class="icon-key"></i> 修改密码',
             'url'=>['/site/change-password'],
             ],

            ['label'=>
            '<i class="icon-signout"></i> 退出',
             'url'=>['/site/logout'],
             'linkOptions'=>['data-method'=>"post"],
             ],
          ],
         ];

        // $menuItems='<li>'
        //     . Html::beginForm(['/site/logout'], 'post')
        //     . Html::submitButton(
        //         '退出 (' . Yii::$app->user->identity->username . ')',
        //         ['class' => 'btn btn-link']
        //     )
        //     . Html::endForm() .
        //  '</li>';
    }

    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-left'],
        'encodeLabels'=>false,
        'items' => $menuItemsLeft,
    ]);

    echo Nav::widget([
        'options' => ['class' => 'navbar-nav navbar-right'],
        'encodeLabels'=>false,
        'items' => $menuItemsRight,
    ]);


    NavBar::end();
    ?>

    <div class="container">
        <?= Breadcrumbs::widget([
            'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
        ]) ?>
        <?= Alert::widget() ?>
        <?= $content ?>
    </div>
</div>

<footer class="footer">
    <div class="container">
        <p class="pull-left">&copy; My Company <?= date('Y') ?></p>

        <p class="pull-right"><?= Yii::powered() ?></p>
    </div>
</footer>

<?php $this->endBody() ?>
</body>
</html>
<?php $this->endPage() ?>
